package com.example.docker_work.controller;


import com.example.docker_work.respose.ReposeMessages;
import com.example.docker_work.service.UpdateExcelService;

import lombok.extern.slf4j.Slf4j;


import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping("file")
@Slf4j
public class FileController {



    @Resource
    private UpdateExcelService updateExcelService;

    @PostMapping("/update")
    public ReposeMessages updated(@RequestBody MultipartFile multipartFile) throws IOException {
        ReposeMessages reposeMessages = null;
        log.info("上传excel文件");
        if (multipartFile == null) {
            return new ReposeMessages("6000001", "文件不能为空!");
        }
        reposeMessages = updateExcelService.updated(multipartFile);
        log.info("文件上传成功！");
        return reposeMessages;
    }
}
